package com.zhou.zhoupicturebackend.api.imagesearch;

import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil;
import cn.hutool.http.Method;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.Request;
import com.squareup.okhttp.Response;
import com.zhou.zhoupicturebackend.api.imagesearch.model.ImageSearchResult;
import com.zhou.zhoupicturebackend.api.imagesearch.sub.GetImageFirstUrlApi;
import com.zhou.zhoupicturebackend.api.imagesearch.sub.GetImageListApi;
import com.zhou.zhoupicturebackend.api.imagesearch.sub.GetImagePageUrlApi;
import com.zhou.zhoupicturebackend.model.entity.Space;
import com.zhou.zhoupicturebackend.service.SpaceService;
import lombok.extern.slf4j.Slf4j;

import javax.annotation.Resource;
import java.io.InputStream;
import java.util.List;

@Slf4j
public class ImageSearchFacade {

    @Resource
    private SpaceService spaceService;

    public static List<ImageSearchResult> searchImage(String imageUrl) {
        String imagePageUrl = GetImagePageUrlApi.getImagePageUrl(imageUrl);
        String imageFirstUrl = GetImageFirstUrlApi.getImageFirstUrl(imagePageUrl);
        return GetImageListApi.getImageList(imageFirstUrl);
    }
}
